package com.Controller;

import com.Service.DepartmentService;
import com.entity.Department;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/subject")
public class DepartmentCcontroller {
    @Autowired
    private DepartmentService departmentService;

    /**
     * 查询
     * @param department
     * @return
     */
    @RequestMapping(value = "/queryDepartment",method = RequestMethod.GET)
    public List<Department> queryDepartment(Department department){
        return departmentService.queryDepartment(department);
    }

    /**
     * 新增
     * @param department
     * @return
     */
    @RequestMapping(value = "/addDepartment",method = RequestMethod.POST)
    public int addDepartment(@RequestBody Department department){
        return departmentService.addDepartment(department);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @RequestMapping(value = "/delDepartment/{id}",method = RequestMethod.DELETE)
    public int delDepartment(@PathVariable int id){
        return departmentService.delDepartment(id);
    }

    /**
     * 修改
     * @param department
     * @return
     */
    @RequestMapping(value = "/updateDepartment/{id}",method = RequestMethod.PUT)
    public int updateDepartment(@RequestBody Department department,@PathVariable int id){
        department.setDepartmentId(id);
        return departmentService.updateDepartment(department);
    }
}
